
from tkinter import *
from tkinter.ttk import *
class WinGUI(Tk):
    def __init__(self):
        super().__init__()
        self.__win()
        self.tk_button_directory = self.__tk_button_directory(self)
        self.tk_input_directory_txt = self.__tk_input_directory_txt(self)
        self.tk_label_label_video = self.__tk_label_label_video(self)
        self.tk_label_label_sub = self.__tk_label_label_sub(self)
        self.tk_text_print = self.__tk_text_print(self)
        self.tk_button_start = self.__tk_button_start(self)
        self.tk_frame_vs_bg = self.__tk_frame_vs_bg(self)
        self.tk_check_button_mp4 = self.__tk_check_button_mp4(self)
        self.tk_check_button_avi = self.__tk_check_button_avi(self)
        self.tk_check_button_mkv = self.__tk_check_button_mkv(self)
        self.tk_check_button_flv = self.__tk_check_button_flv(self)
        self.tk_check_button_ts = self.__tk_check_button_ts(self)
        self.tk_check_button_mov = self.__tk_check_button_mov(self)
        self.tk_check_button_wmv = self.__tk_check_button_wmv(self)
        self.tk_check_button_mp3 = self.__tk_check_button_mp3(self)
        self.tk_check_button_aac = self.__tk_check_button_aac(self)
        self.tk_check_button_ape = self.__tk_check_button_ape(self)
        self.tk_check_button_flac = self.__tk_check_button_flac(self)
        self.tk_check_button_wav = self.__tk_check_button_wav(self)
        self.tk_check_button_alac = self.__tk_check_button_alac(self)
        self.tk_check_button_ogg = self.__tk_check_button_ogg(self)
        self.tk_check_button_srt = self.__tk_check_button_srt(self)
        self.tk_check_button_ass = self.__tk_check_button_ass(self)
        self.tk_check_button_sub = self.__tk_check_button_sub(self)
        self.tk_check_button_ssa = self.__tk_check_button_ssa(self)
        self.tk_check_button_lrc = self.__tk_check_button_lrc(self)
        self.tk_check_button_krc = self.__tk_check_button_krc(self)
        self.tk_check_button_qrc = self.__tk_check_button_qrc(self)
    def __win(self):
        self.title("音视频查找缺失字幕")
        # 设置窗口大小、居中
        width = 800
        height = 560
        screenwidth = self.winfo_screenwidth()
        screenheight = self.winfo_screenheight()
        geometry = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
        self.geometry(geometry)
        
        self.resizable(width=False, height=False)
        
    def scrollbar_autohide(self,vbar, hbar, widget):
        """自动隐藏滚动条"""
        def show():
            if vbar: vbar.lift(widget)
            if hbar: hbar.lift(widget)
        def hide():
            if vbar: vbar.lower(widget)
            if hbar: hbar.lower(widget)
        hide()
        widget.bind("<Enter>", lambda e: show())
        if vbar: vbar.bind("<Enter>", lambda e: show())
        if vbar: vbar.bind("<Leave>", lambda e: hide())
        if hbar: hbar.bind("<Enter>", lambda e: show())
        if hbar: hbar.bind("<Leave>", lambda e: hide())
        widget.bind("<Leave>", lambda e: hide())
    
    def v_scrollbar(self,vbar, widget, x, y, w, h, pw, ph):
        widget.configure(yscrollcommand=vbar.set)
        vbar.config(command=widget.yview)
        vbar.place(relx=(w + x) / pw, rely=y / ph, relheight=h / ph, anchor='ne')
    def h_scrollbar(self,hbar, widget, x, y, w, h, pw, ph):
        widget.configure(xscrollcommand=hbar.set)
        hbar.config(command=widget.xview)
        hbar.place(relx=x / pw, rely=(y + h) / ph, relwidth=w / pw, anchor='sw')
    def create_bar(self,master, widget,is_vbar,is_hbar, x, y, w, h, pw, ph):
        vbar, hbar = None, None
        if is_vbar:
            vbar = Scrollbar(master)
            self.v_scrollbar(vbar, widget, x, y, w, h, pw, ph)
        if is_hbar:
            hbar = Scrollbar(master, orient="horizontal")
            self.h_scrollbar(hbar, widget, x, y, w, h, pw, ph)
        self.scrollbar_autohide(vbar, hbar, widget)
    def __tk_button_directory(self,parent):
        btn = Button(parent, text="选择目录", takefocus=False,)
        btn.place(x=20, y=20, width=100, height=30)
        return btn
    def __tk_input_directory_txt(self,parent):
        ipt = Entry(parent, )
        ipt.place(x=120, y=20, width=659, height=30)
        return ipt
    def __tk_label_label_video(self,parent):
        label = Label(parent,text="选择音视频",anchor="center", )
        label.place(x=20, y=60, width=80, height=30)
        return label
    def __tk_label_label_sub(self,parent):
        label = Label(parent,text="选择字幕",anchor="center", )
        label.place(x=120, y=60, width=80, height=30)
        return label
    def __tk_text_print(self,parent):
        text = Text(parent)
        text.place(x=219, y=101, width=560, height=438)
        return text
    def __tk_button_start(self,parent):
        btn = Button(parent, text="开始检测", takefocus=False,)
        btn.place(x=220, y=60, width=420, height=30)
        return btn
    def __tk_frame_vs_bg(self,parent):
        frame = Frame(parent,)
        frame.place(x=20, y=100, width=198, height=439)
        return frame
    def __tk_check_button_mp4(self,parent):
        cb = Checkbutton(parent,text="mp4",)
        cb.place(x=20, y=100, width=82, height=30)
        return cb
    def __tk_check_button_avi(self,parent):
        cb = Checkbutton(parent,text="avi",)
        cb.place(x=20, y=160, width=75, height=30)
        return cb
    def __tk_check_button_mkv(self,parent):
        cb = Checkbutton(parent,text="mkv",)
        cb.place(x=20, y=130, width=80, height=30)
        return cb
    def __tk_check_button_flv(self,parent):
        cb = Checkbutton(parent,text="flv",)
        cb.place(x=20, y=190, width=70, height=30)
        return cb
    def __tk_check_button_ts(self,parent):
        cb = Checkbutton(parent,text="ts",)
        cb.place(x=20, y=280, width=70, height=30)
        return cb
    def __tk_check_button_mov(self,parent):
        cb = Checkbutton(parent,text="mov",)
        cb.place(x=20, y=220, width=82, height=30)
        return cb
    def __tk_check_button_wmv(self,parent):
        cb = Checkbutton(parent,text="wmv",)
        cb.place(x=20, y=250, width=85, height=30)
        return cb
    def __tk_check_button_mp3(self,parent):
        cb = Checkbutton(parent,text="mp3",)
        cb.place(x=20, y=320, width=83, height=30)
        return cb
    def __tk_check_button_aac(self,parent):
        cb = Checkbutton(parent,text="aac",)
        cb.place(x=20, y=350, width=80, height=30)
        return cb
    def __tk_check_button_ape(self,parent):
        cb = Checkbutton(parent,text="ape",)
        cb.place(x=20, y=500, width=84, height=30)
        return cb
    def __tk_check_button_flac(self,parent):
        cb = Checkbutton(parent,text="flac",)
        cb.place(x=20, y=440, width=80, height=30)
        return cb
    def __tk_check_button_wav(self,parent):
        cb = Checkbutton(parent,text="wav",)
        cb.place(x=20, y=470, width=81, height=30)
        return cb
    def __tk_check_button_alac(self,parent):
        cb = Checkbutton(parent,text="alac",)
        cb.place(x=20, y=410, width=82, height=30)
        return cb
    def __tk_check_button_ogg(self,parent):
        cb = Checkbutton(parent,text="ogg",)
        cb.place(x=20, y=380, width=81, height=30)
        return cb
    def __tk_check_button_srt(self,parent):
        cb = Checkbutton(parent,text="srt(字幕)",)
        cb.place(x=119, y=100, width=85, height=30)
        return cb
    def __tk_check_button_ass(self,parent):
        cb = Checkbutton(parent,text="ass(字幕)",)
        cb.place(x=120, y=130, width=86, height=30)
        return cb
    def __tk_check_button_sub(self,parent):
        cb = Checkbutton(parent,text="sub(字幕)",)
        cb.place(x=120, y=160, width=87, height=30)
        return cb
    def __tk_check_button_ssa(self,parent):
        cb = Checkbutton(parent,text="ssa(字幕)",)
        cb.place(x=120, y=190, width=87, height=30)
        return cb
    def __tk_check_button_lrc(self,parent):
        cb = Checkbutton(parent,text="lrc(歌词)",)
        cb.place(x=120, y=320, width=83, height=30)
        return cb
    def __tk_check_button_krc(self,parent):
        cb = Checkbutton(parent,text="krc(歌词)",)
        cb.place(x=120, y=350, width=87, height=30)
        return cb
    def __tk_check_button_qrc(self,parent):
        cb = Checkbutton(parent,text="qrc(歌词)",)
        cb.place(x=120, y=380, width=87, height=30)
        return cb
class Win(WinGUI):
    def __init__(self, controller):
        self.ctl = controller
        super().__init__()
        self.__event_bind()
        self.__style_config()
        self.ctl.init(self)
    def __event_bind(self):
        self.tk_button_directory.bind('<Button-1>',self.ctl.directory)
        self.tk_button_start.bind('<Button-1>',self.ctl.start)
        pass
    def __style_config(self):
        pass
if __name__ == "__main__":
    win = WinGUI()
    win.mainloop()